<?php
class PostSaveAllAction extends AdminAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'json';
	}
	
	public function execute()
	{
		$ids	= $this->context->post('id');
		$op		= $this->context->post('op');
		if(empty($ids))
		{
			$this->code	= 200;
		}
		else
		{
			$postService	= new PostService();
			$idSql			= $postService->getInSql($ids);
			$condition['expression']	= 'id in('.$idSql.')';
			switch($op)
			{
				case 'del':
					$postService->deleteByIds($ids);
					break;
				case 'admit':
					$postService->updateRows($condition,array('status'=>1));
					break;
				case 'unadmit':
					$postService->updateRows($condition,array('status'=>0));
					break;
				case 'recommend':
					$postService->updateRows($condition,array('suggest'=>1));
					break;
				case 'unrecommend':
					$postService->updateRows($condition,array('suggest'=>0));
					break;
			}
			$this->code	= 200;
		}
	}
}
